# Contributor: Bart Ribbers <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-applications
maintainer="team/kde <bribbers@disroot.org>"
pkgname=messagelib
pkgver=24.08.2
pkgrel=0
pkgdesc="KDE PIM messaging library"
# armhf blocked by extra-cmake-modules
# armv7, ppc64le, s390x, riscv64 blocked by qt6-qtwebengine
# loongarch64 blocked by pimcommon
arch="all !armv7 !armhf !ppc64le !s390x !riscv64 !loongarch64"
url="https://kontact.kde.org/"
license="LGPL-2.0-only OR LGPL-3.0-only AND GPL-2.0-or-later"
depends_dev="
	akonadi-contacts-dev
	akonadi-dev
	akonadi-mime-dev
	akonadi-search-dev
	gpgme-dev
	grantlee-dev
	grantleetheme-dev
	karchive-dev
	kcodecs-dev
	kcompletion-dev
	kconfig-dev
	kconfigwidgets-dev
	kcontacts-dev
	kdbusaddons-dev
	ki18n-dev
	kiconthemes-dev
	kidentitymanagement-dev
	kio-dev
	kitemviews-dev
	kjobwidgets-dev
	kldap-dev
	kmailtransport-dev
	kmbox-dev
	kmime-dev
	knewstuff-dev
	kpimtextedit-dev
	kservice-dev
	ktextwidgets-dev
	kwidgetsaddons-dev
	kwindowsystem-dev
	kxmlgui-dev
	libgravatar-dev
	libkdepim-dev
	libkleo-dev
	pimcommon-dev
	qca-qt6-dev
	qt6-qtbase-dev
	qt6-qtwebengine-dev
	sonnet-dev
	syntax-highlighting-dev
	"
makedepends="$depends_dev
	doxygen
	extra-cmake-modules
	graphviz
	samurai
	"
checkdepends="
	dbus
	procps-ng
	xvfb-run
	"
subpackages="$pkgname-dev $pkgname-lang"
_repo_url="https://invent.kde.org/pim/messagelib.git"
source="https://download.kde.org/stable/release-service/$pkgver/src/messagelib-$pkgver.tar.xz"

case "$CARCH" in
	x86) options="$options !check";;
esac

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_QCH=ON
	cmake --build build
}

check() {
	local skipped_tests="(mimetreeparser-bodypartformatterbasefactory"
	local tests="
		messageviewer-scamwebenginedetection-scamdetectionwebengine
		messageviewer-messageparttheme-objecttreeparser
		messageviewer-messageparttheme-render
		messageviewer-messageparttheme-unencryptedmessage
		messageviewer-messageparttheme-showonlymimepart
		messageviewer-dkimchecksignaturejob
		akonadi-mysql-viewer
		akonadi-sqlite-viewer
		templateparser-templateextracttextfrommail
		templateparser-templateextracthtmlelementfrommail
		templateparser-templateparserjob
		messagecomposer-messagefactoryng
		messagecomposer-replystrategy
		messagecomposer-cryptocomposer
		messagecomposer-composerviewbase
		messagecore-autocryptrecipient
		messageviewer-webengine-webengineaccesskeyanchorfromhtml
		webengineviewer-findbar-findbarbase
		webengineview-createdatabasefilejob
		"
	case "$CARCH" in
		x86) tests="$tests webengineviewer-webengineexportpdfpagejobtest" ;;
	esac
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)test"

	dbus-run-session xvfb-run ctest --test-dir build --output-on-failure -E "$skipped_tests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
189117a5da171e49437c24635f9102480457cc82426f44ab8ad65001db2889bde785540b3b73a2f1dc4630c278618d007ed4dcd7ea5d73617f7d2d3bc7480a9e  messagelib-24.08.2.tar.xz
"
